home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 657 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.7 KB  |  54 lines

  1. Path: hickory.soton.ac.uk!newsmaster
  2. From: jcridge <jcridge@mail.soton.ac.uk>
  3. Newsgroups: comp.lang.c++
  4. Subject: Borland C++ v4.02: TIArrayAsVector container class within another class
  5. Date: 5 Jan 1996 16:23:57 GMT
  6. Organization: Computing Services, University of Southampton
  7. Message-ID: <4cjjat$bqj@hickory.soton.ac.uk>
  8. NNTP-Posting-Host: jcridge.maths.soton.ac.uk
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=us-ascii
  11. Content-Transfer-Encoding: 7bit
  12. X-Mailer: Mozilla 1.22 (Windows; I; 16bit)
  13.  
  14. Could anyone confirm that the following (below) is the correct way to create a new class which 
  15. contains  a TIArrayAsVector container class as one of its data members? 
  16.  
  17. The only example that I could find in the manuals was tucked away in the 
  18. BC4:\examples\classlib\testdir subdirectory. The example in the programmers guide made things 
  19. more complicated by involving a template class structure aswell which doesn't help; the 
  20. programmers guide also mislabelled the \testdir directory as \directry (pp229), but it would 
  21. appear that the syntax below is correct if a little awkward and non-intuitive.  
  22.  
  23. The simple example below appears to compile, but my program is crashing for some reason when I 
  24. try to use getch() later on...
  25.  
  26.  
  27. //////////////////////////////////////////////////////////////////////////////////////////////
  28.  
  29. //header file....
  30.  
  31. class anotherclass
  32.         {public:
  33.                 anotherclass(); 
  34.                 int a;
  35.         }
  36.  
  37. class myclass
  38.     {public:
  39.         myclass();
  40.         TIArrayAsVector<anotherclass>  arrayname;    
  41.      };
  42.  
  43.  
  44. //cpp file
  45.  
  46. tsectorbase::tsectorbase():arrayname(1,1,1)
  47.     {...}
  48.  
  49. anotherclass::anotherclass()
  50.         {a=0;}  
  51.  
  52. ///////////////////////////////////////////////////////////////////////////////////////////
  53.  
  54.